package com.example.sys.Mapper;
import com.example.sys.Enity.StudentInfo;
import com.example.sys.vo.StudentInfoClassInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudentInfoMapper {
    @Select("select * from student_info where stu_name like '%${name}%'")
    List<StudentInfo> getAllStudentInfo(String name);
    @Select("select stu.*,cls.className from student_info stu join classinfo cls on stu.clsid=cls.clsid where stu_name like '%${stuName}%'")
    List<StudentInfoClassInfo>getAllStuAndClassByName(String stuName);

    @Delete("delete from student_info where stuid=#{stuid}")
    Integer deleteByID(Integer stuid);

    @Select("select stu.*,cls.className from student_info stu join classinfo cls on stu.clsid=cls.clsid\n" +
            " where stu_name like '%${stuName}%' and stu.clsid=#{clsid}")
    List<StudentInfoClassInfo> getAllStuAndClassByclsAndName(@Param("stuName") String stuName,@Param("clsid") Integer clsid);

    @Insert("insert into student_info ( stu_no, stu_name, stu_sex, stu_birthday, stu_education, stu_interest, my_color, create_date, clsid)\n" +
            "values(#{stu_no},#{stu_name},#{stu_sex},#{stu_birthday},#{stu_education},#{stu_interest},#{my_color},#{create_date},#{clsid})")
    Integer insertStudentInfo(StudentInfo studentInfo);
}
